package com.example.hystrix;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author WuGang
 * @Date 2022/11/10 14:07
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
public class A {
    @HystrixCommand(fallbackMethod = "hystrix")
    @GetMapping("/login")
    public String login() {
//        有异常表示调用服务不通，避免堵塞请求，自动熔断
        int i = 1 / 0;
        return "wugang";
    }

    public String hystrix() {
        System.out.println("熔断后回调方法执行了");
        return "hystrix";
    }
}
